#ifndef __IIC_PERIPHERAL_H
#define __IIC_PERIPHERAL_H

#include "stdint.h"

#define IIC_PERI_USE_FULL_ASSERT 0

#define IIC0_SLAVE_ADDRESS7 0x82
#define IIC1_SLAVE_ADDRESS7 0x72

#if IIC_PERI_USE_FULL_ASSERT
	void IICAssertPointNULL(uint8_t *file, uint32_t line);
	#define IIC_ASSERT_POINT_NULL(expr) ((expr) ? (void)0 : IICAssertPointNULL((uint8_t *)__FILE__, __LINE__))
#else
	#define IIC_ASSERT_POINT_NULL(expr) ((void)0)
#endif

typedef void (* IICDelayMs)(uint32_t ms);

typedef enum {IIC_PERIPHERAL0, IIC_PERIPHERAL1} IIC_PERI_E;

typedef enum {
	IIC_SPEED_100KHZ = 100000,
	IIC_SPEED_400KHZ = 400000,
	IIC_SPEED_1MHZ = 1000000
} IIC_PERI_SPEED_E;

uint8_t IICMasterDeInit(IIC_PERI_E iic, IIC_PERI_SPEED_E speed, IICDelayMs delay);
void IICSetDelay(IICDelayMs delay);

uint8_t IICMasterSendOneData(IIC_PERI_E iic, uint32_t slaveAddr, uint8_t data, uint16_t timeout);
uint8_t IICMasterSendArray(IIC_PERI_E iic, uint32_t slaveAddr, uint8_t *array, uint16_t len, uint16_t timeout);
uint8_t IICMasterWriteOneReg(IIC_PERI_E iic, uint32_t slaveAddr, uint8_t regAddr, uint8_t regVal, uint16_t timeout);
uint8_t IICMasterReceiveOneData(IIC_PERI_E iic, uint32_t slaveAddr, uint8_t *data, uint16_t timeout);
uint8_t IICMasterReceiveArray(IIC_PERI_E iic, uint32_t slaveAddr, uint8_t *array, uint16_t len, uint16_t timeout);

#endif
